package top.arryweb.application.common.constant;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * 枚举处理器，在启动后加载，缓存特定处理
 *
 * @author xiong04
 * @since 2021-05-04
 */
@Component
public class ConstantEnumHandler implements InitializingBean {

	@Autowired
	private ApplicationContext applicationContext;

	public static final Map<PayStatus, List<PayStatus>> UPDATE_ORDER_STATUS_MAP = new HashMap<>();

	private void judgePayStatus(){
	}

	private void initUpdateOrderPayStatusMap(){
		UPDATE_ORDER_STATUS_MAP.put(PayStatus.SUCCEED, Collections.singletonList(PayStatus.TO_BE_PAID));
		UPDATE_ORDER_STATUS_MAP.put(PayStatus.FAIL,Collections.singletonList(PayStatus.TO_BE_PAID));
		UPDATE_ORDER_STATUS_MAP.put(PayStatus.REVOKED,Collections.singletonList(PayStatus.TO_BE_PAID));
		UPDATE_ORDER_STATUS_MAP.put(PayStatus.PARTIAL_REFUND,Arrays.asList(PayStatus.SUCCEED,PayStatus.PARTIAL_REFUND));
		UPDATE_ORDER_STATUS_MAP.put(PayStatus.REFUNDED,Arrays.asList(PayStatus.PARTIAL_REFUND,PayStatus.SUCCEED));
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		initUpdateOrderPayStatusMap();
		System.out.println("map的长度"+ UPDATE_ORDER_STATUS_MAP.size());

	}
}
